package ifi.sma.group5.models;

import ifi.sma.group5.db.Db;

import java.util.ArrayList;
import java.util.Map;

public class CoursModel {
	public int id;
	public String DescriptionCours;
	public String TitreCours;
	public CoursModel[] getAll() throws Exception
	{
		Db db = new Db("Cours");
		ArrayList<Map<String, String>> datas = db.get("select * from Cours");
		if(datas != null)
		{
			CoursModel[] ls = new CoursModel[datas.size()];
			for(int i=0;i<datas.size();i++)
			{
				ls[i] = new CoursModel();
				ls[i].id = Integer.parseInt(datas.get(i).get("IdCours"));
				ls[i].DescriptionCours = datas.get(i).get("DescriptionCours");
				ls[i].TitreCours = datas.get(i).get("TitreCours");
			}
			return ls;
			
		}
		return null;
	}
}

